<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>AI 面试系统 - 我的面试</title>
    <link
      href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css"
      rel="stylesheet"
    />
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css"
    />
  </head>
  <body>
    <nav
      class="navbar navbar-expand-lg navbar-dark"
      style="
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
      "
    >
      <div class="container">
        <a class="navbar-brand d-flex align-items-center" href="#">
          <i class="bi bi-robot me-2" style="font-size: 1.5rem"></i>
          AI 面试系统
        </a>
        <button
          class="navbar-toggler border-0"
          type="button"
          data-bs-toggle="collapse"
          data-bs-target="#navbarNav"
        >
          <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
          <ul class="navbar-nav ms-auto">
            <li class="nav-item">
              <span class="nav-link d-flex align-items-center">
                <i class="bi bi-person-circle me-2"></i>
                欢迎, [[${#authentication?.principal?.username ?: '游客'}]]
              </span>
            </li>
            <li class="nav-item">
              <a class="nav-link active d-flex align-items-center" href="#">
                <i class="bi bi-list-ul me-2"></i> 我的面试
              </a>
            </li>
            <li class="nav-item">
              <a
                class="nav-link d-flex align-items-center"
                th:href="@{/interview}"
              >
                <i class="bi bi-plus-circle me-2"></i> 开始新的面试
              </a>
            </li>
            <li class="nav-item">
              <a
                class="nav-link d-flex align-items-center"
                th:href="@{/logout}"
              >
                <i class="bi bi-box-arrow-right me-2"></i>退出登录
              </a>
            </li>
          </ul>
        </div>
      </div>
    </nav>

    <div class="container mt-4">
      <div class="row">
        <div class="col-lg-10 offset-lg-1">
          <div class="d-flex align-items-center justify-content-between mb-4">
            <div>
              <h2 class="mb-1 d-flex align-items-center">
                <i
                  class="bi bi-clipboard-data text-primary me-3"
                  style="font-size: 2rem"
                ></i>
                我的面试记录
              </h2>
              <p class="text-muted mb-0">查看您的AI面试历史和评估结果</p>
            </div>
            <a
              th:href="@{/interview}"
              class="btn btn-primary btn-lg"
              style="
                background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
                border: none;
                border-radius: 15px;
              "
            >
              <i class="bi bi-plus-circle me-2"></i> 开始新面试
            </a>
          </div>

          <div th:if="${interviews.isEmpty()}" class="text-center py-5">
            <div class="card border-0 shadow-lg" style="border-radius: 20px">
              <div class="card-body p-5">
                <i
                  class="bi bi-clipboard-x text-primary mb-4"
                  style="font-size: 4rem"
                ></i>
                <h4 class="text-primary mb-3">还没有面试记录</h4>
                <p class="text-muted mb-4">
                  您还没有进行过任何面试。AI面试系统将根据您的简历和目标职位，<br />
                  生成个性化的面试问题，帮助您更好地准备面试。
                </p>
                <a
                  th:href="@{/interview}"
                  class="btn btn-primary btn-lg px-4"
                  style="
                    background: linear-gradient(
                      135deg,
                      #667eea 0%,
                      #764ba2 100%
                    );
                    border: none;
                    border-radius: 15px;
                  "
                >
                  <i class="bi bi-rocket-takeoff me-2"></i> 开始您的第一次面试
                </a>
              </div>
            </div>
          </div>

          <div
            th:unless="${interviews.isEmpty()}"
            class="card border-0 shadow-lg"
            style="border-radius: 20px; overflow: hidden"
          >
            <div
              class="card-header text-white"
              style="
                background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
                border: none;
              "
            >
              <h5 class="mb-0 d-flex align-items-center">
                <i class="bi bi-list-check me-2"></i>
                面试记录列表
              </h5>
            </div>
            <div class="card-body p-0">
              <div class="table-responsive">
                <table class="table table-hover mb-0">
                  <thead class="table-light">
                    <tr>
                      <th class="border-0 px-4 py-3">
                        <i class="bi bi-calendar-event me-2 text-primary"></i
                        >面试时间
                      </th>
                      <th class="border-0 px-4 py-3">
                        <i class="bi bi-briefcase me-2 text-primary"></i
                        >目标职位
                      </th>
                      <th class="border-0 px-4 py-3">
                        <i class="bi bi-star me-2 text-primary"></i>评分
                      </th>
                      <th class="border-0 px-4 py-3">
                        <i class="bi bi-gear me-2 text-primary"></i>操作
                      </th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr
                      th:each="interview : ${interviews}"
                      class="border-bottom"
                    >
                      <td class="px-4 py-3">
                        <div class="d-flex align-items-center">
                          <div
                            class="bg-primary bg-opacity-10 rounded-circle p-2 me-3"
                          >
                            <i class="bi bi-calendar-check text-primary"></i>
                          </div>
                          <div>
                            <span
                              th:if="${interview.endTime != null}"
                              th:text="${interview.endTime}"
                              class="fw-semibold"
                            ></span>
                            <span
                              th:if="${interview.endTime == null}"
                              class="badge bg-warning text-dark"
                              >进行中</span
                            >
                          </div>
                        </div>
                      </td>
                      <td class="px-4 py-3">
                        <div class="d-flex align-items-center">
                          <div
                            class="bg-info bg-opacity-10 rounded-circle p-2 me-3"
                          >
                            <i class="bi bi-briefcase text-info"></i>
                          </div>
                          <span class="fw-semibold"
                            >[[${interview.jobPosition}]]</span
                          >
                        </div>
                      </td>
                      <td class="px-4 py-3">
                        <span
                          th:if="${interview.finalScore != null}"
                          class="badge fs-6 px-3 py-2"
                          th:class="${interview.finalScore >= 7} ? 'bg-success' : (${interview.finalScore >= 4} ? 'bg-warning' : 'bg-danger')"
                        >
                          <i class="bi bi-star-fill me-1"></i>
                          [[${#numbers.formatDecimal(interview.finalScore, 1,
                          'COMMA', 1, 'POINT')}]]/10
                        </span>
                        <span
                          th:if="${interview.finalScore == null}"
                          class="badge bg-secondary fs-6 px-3 py-2"
                        >
                          <i class="bi bi-clock me-1"></i>未完成
                        </span>
                      </td>
                      <td class="px-4 py-3">
                        <div class="btn-group" role="group">
                          <a
                            th:if="${interview.status.name() == 'COMPLETED'}"
                            th:href="@{/result/{id}(id=${interview.id})}"
                            class="btn btn-sm btn-success"
                            title="查看面试结果"
                            style="border-radius: 8px"
                          >
                            <i class="bi bi-eye me-1"></i>查看结果
                          </a>
                          <a
                            th:if="${interview.status.name() == 'IN_PROGRESS'}"
                            th:href="@{/chat-interview/{id}(id=${interview.id})}"
                            class="btn btn-sm btn-warning"
                            title="继续面试"
                            style="border-radius: 8px"
                          >
                            <i class="bi bi-play-circle me-1"></i>继续面试
                          </a>
                          <a
                            th:href="@{/debug-interview/{id}(id=${interview.id})}"
                            class="btn btn-sm btn-outline-info"
                            title="调试信息"
                            style="border-radius: 8px"
                          >
                            <i class="bi bi-bug"></i>
                          </a>
                        </div>
                      </td>
                    </tr>
                  </tbody>
                </table>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
  </body>
</html>
